﻿using System;
using System.Web.Security;
using System.Web.UI.WebControls;

namespace Admin
{
    public partial class UserManagement : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUserCollection users;

            if (Cache[Constants.Cache.Users] == null)
            {
                users = Membership.GetAllUsers();
                Cache.Add(
                    Constants.Cache.Users,
                    users,
                    null,
                    System.Web.Caching.Cache.NoAbsoluteExpiration,
                    new TimeSpan(0, 1, 0), //1 minute cache just for paging
                    System.Web.Caching.CacheItemPriority.Normal,
                    null);
            }
            else
            {
                users = Cache[Constants.Cache.Users] as MembershipUserCollection;
            }

            gvUsers.DataSource = users;
            gvUsers.DataBind();
        }

        protected void gvUsers_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvUsers.PageIndex = e.NewPageIndex;
            gvUsers.DataBind();
        }
    }
}